<template>
  <a-card style="width: 100%" title="协议列表">
    <template #extra>
      <a-tooltip placement="top">
        <template #title>
          <span>返回上级</span>
        </template>
        <a-button size="small" @click="getOut"> <RollbackOutlined /></a-button>
      </a-tooltip>
    </template>
    <a-row class="smart-table-btn-block">
      <div class="smart-table-operate-block"></div>
      <div class="smart-table-setting-block">
        <TableOperator v-model="columns" :tableId="TABLE_ID_CONST.BUSINESS.OA.ENTERPRISE" :refresh="getInitDate" />
      </div>
    </a-row>
    <a-table size="small" :dataSource="tableData" :columns="columns" rowKey="enterpriseId" :pagination="false" :loading="tableLoading" bordered>
      <template #bodyCell="{ column, record, text }">
        <template v-if="column.dataIndex === 'blext3'" title="下载">
          <div class="smart-table-operate">
            <span style="color: #1677ff"><a :href="record.blext3" target="_blank">下载</a></span>
          </div>
        </template>
        <template v-if="column.dataIndex === 'blext4'" title="签订时间">
          <div class="smart-table-operate">
            <span>{{ record.blext4 + '-' + record.blext5 + '-' + record.blext6 }}</span>
          </div>
        </template>
      </template>
    </a-table>
  </a-card>
  <br />
</template>

<script setup>
  import { reactive, ref, onMounted, defineEmits, defineProps } from 'vue';
  import { message, Modal } from 'ant-design-vue';
  import { SmartLoading } from '/@/components/framework/smart-loading';
  import { PAGE_SIZE, PAGE_SIZE_OPTIONS } from '/@/constants/common-const';
  import TableOperator from '/@/components/support/table-operator/index.vue';
  import { TABLE_ID_CONST } from '/@/constants/support/table-id-const';
  import { smartSentry } from '/@/lib/smart-sentry';
  import { Fundingapproval } from '../../../../api/Fundingapproval/Fundingapproval-api';
  //--------------------------- 表格 列 ---------------------------
  const columns = ref([
    {
      title: '协议名称',
      dataIndex: 'blext7',
      align: 'center',
      width: 150,
    },
    {
      title: '签订时间',
      dataIndex: 'blext4',
      align: 'center',
    },

    {
      title: '下载',
      dataIndex: 'blext3',
      align: 'center',
    },
  ]);
  const queryFormState = {
    page: 1,
    limit: PAGE_SIZE,
  };
  const queryForm = reactive({ ...queryFormState });
  const tableLoading = ref(false);
  const tableData = ref([]);
  const total = ref(0);
  //拿到数据id查看该数据的操作记录

  async function getInitDate() {
    getFindLook();
  }
  const emit = defineEmits();
  // //查看协议加下载
  const props = defineProps({
    DataId: String,
  });
  const getFindLook = async () => {
    let obj = {
      projectNum: props.DataId,
    };
    try {
      let res = await Fundingapproval.DowloadProval(obj);
      console.log(res, '协议下载');
      tableData.value = res.data;
    } catch (error) {
      smartSentry.captureError(error);
    }
  };
  //返回表格
  const getOut = () => {
    let obj = {
      type: 0,
    };
    emit('getBlack', obj);
  };
  onMounted(() => {
    getInitDate();
  });
</script>

<style lang="scss" scoped></style>
